classDiagram
    class Subject {
        <<interface>>
        -observers: list
        +attach(observer: Observer): void
        +detach(observer: Observer): void
        +notify(): void
    }
    class Observer {
        <<interface>>
        +update(subject: Subject): void
    }
    class ConcreteSubject {
        -observers: list
        -state: int
        +attach(observer: Observer): void
        +detach(observer: Observer): void
        +notify(): void
        +getState(): int
        +setState(state: int): void
    }
    class ConcreteObserverA {
        +update(subject: Subject): void
    }
    class ConcreteObserverB {
        +update(subject: Subject): void
    }

    Subject <|.. ConcreteSubject
    Observer <|.. ConcreteObserverA
    Observer <|.. ConcreteObserverB
    ConcreteSubject o-- Observer : notifies
